<template>
  <div class="content">
      <ul class="flex-box">
        <li><span>收据名字：</span></li>
        <li><input maxlength="30" readonly="readonly" type="text" placeholder="" v-model="name"></li>
        <li></li>
      </ul>
      <ul class="flex-box">
        <li><span>收据单号：</span></li>
        <li><input type="text" maxlength="30" v-model="num" placeholder="请输入单号"></li>
        <li><img @click="emtpy()" v-if="isEm" class="more-icon" src="~assets/img/icon_de@2x.png" alt=""></li>
      </ul>
       <div class="tc"><button style="background:#fff;color:#333;opacity:1" class="common-btn" v-if="!isShow" @click="submit()">审核中</button></div>
        <div class="tc"><button class="common-btn" style="opacity:1" v-if="!isShow" @click="refre()">刷新</button></div>
  </div>
</template>
<script>
import { Indicator, MessageBox } from 'mint-ui'
import Mock from 'mockjs'
export default {
  data () {
    return {
      readonly: false,
      name: '',
      isEm: false,
      num: ''
    }
  },
  mounted () {
    this.$apiPost('userinfo',{}).then((data) => {
      this.name = data.data.account_info.name
    })
    this.$apiPost('userstatus',{}).then((data) => {
      if (data.status === 0) {
         if (data.data.recode === 1005) {
            this.$router.push('/user')
          }
      } else {
        MessageBox({title: '提示',message: data.msg})
      }
    })
  },
  methods: {
    refre () {
      Indicator.open({
        text: 'Loading...',
        spinnerType: 'fading-circle'
      })
     this.$apiPost(`wait_refresh`,{})
        .then(data => {
          if (data.data.recode === 0) {
            setTimeout(() => {
              MessageBox({
                title: '提示',
                message: '正在审核中，请耐心等待。。'
              })
               Indicator.close()
            }, 1000)
          } else if (data.data.recode === 1) {
            setTimeout(() => {
              MessageBox({
                title: '审核成功',
                message:
                  '您已成功成为艾鑫电子商务一员，赶快快去体验电子商务的功能吧！'
              })
               Indicator.close()
              this.$router.push('/user')
            }, 1000)
          } else if (data.data.code === 2) {
            setTimeout(() => {
              MessageBox({
                title: '提示',
                message: '审核失败，请核对您的信息'
              })
               Indicator.close()
            }, 1000)
          }
        })
        Indicator.close()
    },
    submit () {},
    emtpy () {
      this.num = ''
    }
  },
  watch: {
    num (newN, oldN) {
      if (newN.length > 0) {
        this.isEm = true
        this.$refs.btn.style.opacity = '1'
      } else {
        this.isEm = false
         this.$refs.btn.style.opacity = '0.5'
      }
    }
  }
}
</script>
<style scoped>
</style>
